package javao.cn.modules.business.service.impl;

import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import javao.cn.common.utils.PageUtils;
import javao.cn.common.utils.Query;

import javao.cn.modules.business.dao.SysLunboDao;
import javao.cn.modules.business.entity.SysLunboEntity;
import javao.cn.modules.business.service.SysLunboService;


@Service("sysLunboService")
public class SysLunboServiceImpl extends ServiceImpl<SysLunboDao, SysLunboEntity> implements SysLunboService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<SysLunboEntity> page = this.page(
                new Query<SysLunboEntity>().getPage(params),
                new QueryWrapper<SysLunboEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public PageUtils queryPageByDesc(Map<String, Object> params) {
        // 创建 QueryWrapper 并设置排序规则
        QueryWrapper<SysLunboEntity> wrapper = new QueryWrapper<>();

        // 默认按照 sort 字段升序排序
        String orderByField = "sort";
        Boolean isAsc = true; // 默认为升序
        // 设置排序规则
        wrapper.orderBy(true, isAsc, orderByField);
        // 执行分页查询
        IPage<SysLunboEntity> page = this.page(
                new Query<SysLunboEntity>().getPage(params),
                wrapper
        );
        return new PageUtils(page);
    }

}